package com.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
 
/**
 * 文件上传拦截器
 * @ClassName: FileUploadInterceptor
 * @Description:
 * @author weiyb
 * @date 2018年5月7日 上午11:51:53
 */

public class FileUploadInterceptor implements HandlerInterceptor {
	/*
	 * 视图渲染之后的操作
	 */
	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
 
	}
 
	/*
	 * 处理请求完成后视图渲染之前的处理操作
	 */
	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
 
	}
 
	/*
	 * 进入controller层之前拦截请求
	 */
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
//		String token =  request.getHeader("TOKEN");
//		System.out.println("拦截器触发");
//		System.out.println(token);
//		if(token == null){
//			response.getWriter().println("无token");
//			return false;
//		}else{
//            return true;
//        }
		return true;
	}
 
}



 